home *** CD-ROM | disk | FTP | other *** search
/ PC Open 93 / PC Open 93 CD 2.bin / PDF / webdeveloper / lezione_4 / gestione_inserisci.asp < prev    next >
Encoding:
Text File  |  2003-12-10  |  2.2 KB  |  132 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2.  
  3. <html>
  4. <head>
  5.     <title>Gestione foto di Mario Rossi</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <h1>Gestione foto</h1>
  11.  
  12.  
  13. <%
  14.  
  15. Const adOpenForwardOnly = 0
  16. Const adLockReadOnly = 1
  17.  
  18. Dim contatore
  19. Dim sql1,sql2
  20. Dim conn, rs
  21. Dim pagNum
  22. Dim pagSize
  23. Dim i,j
  24.  
  25. pagSize = 2
  26.  
  27. Set conn = Server.CreateObject("ADODB.Connection")
  28. conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/foto2.mdb")
  29.  
  30. sql1 = "SELECT count(nome) AS contatore FROM Foto"
  31. sql2 = "SELECT * FROM Foto ORDER BY Data DESC"
  32.  
  33. Set rs = Server.CreateObject("ADODB.RecordSet")
  34. rs.Open sql1, conn, adOpenForwardOnly, adLockReadOnly
  35.  
  36. contatore = rs("contatore")
  37.  
  38. rs.Close()
  39.  
  40.  
  41. 'Estrae il numero di pagina
  42. pagNum = cint(request.QueryString("pag"))
  43. If pagNum = 0 Then pagNum = 1
  44.  
  45. 'Imposta la dimensione della pagina (il numero massimo di elementi da far comparire per ogni pagina)
  46. rs.PageSize = pagSize
  47.  
  48. rs.Open sql2, conn, 3, adLockReadOnly
  49.  
  50. %>
  51.  
  52. Foto presenti nella base di dati: <%=contatore%><br><br>
  53. Inserisci una <a href="inseriscifoto.asp">nuova foto</a>
  54. <%
  55.  
  56.  
  57. rs.AbsolutePage = pagNum
  58.  
  59. for i = 1 to pagSize
  60.  
  61.     if not rs.EOF Then
  62.  
  63.         if i mod 2 = 0 then
  64.             strColor="#3333CC"
  65.         else
  66.             strColor="#FF0033"
  67.         end if
  68.  
  69. %>
  70.  
  71. <li>
  72.     <a style="color:<%=strColor%>" href="dettagliofoto.asp?nome=<%=rs("Nome")%>"><%=rs("Titolo")%>, scattata a <%=rs("Luogo")%></a>
  73. </li>
  74.  
  75. <%
  76.         rs.movenext
  77.  
  78.     Else
  79.  
  80.         Exit For
  81.  
  82.     End If
  83.  
  84.  
  85. next
  86.  
  87. %>
  88.  
  89. <br><hr><br>
  90.  
  91. <div align="left">
  92.  
  93. <%
  94.     If pagNum > 1 Then
  95. %>
  96.     <a href="<%=request.ServerVariables("PATH_INFO")%>?pag=<%=pagNum -1%><%=strTipo%>">«</a>
  97. <%
  98.     End If
  99. %>
  100.  
  101. <% for j = 1 to rs.PageCount %>
  102.     <% if j = pagNum then %>
  103.         <%=j%>
  104.     <% else %>
  105.         <a href="<%=request.ServerVariables("PATH_INFO")%>?pag=<%=j%><%=strTipo%>"><%=j%></a>
  106.     <% end if %>
  107. <% next %>
  108.  
  109. <%
  110.     If pagNum < rs.PageCount Then
  111. %>
  112.     <a href="<%=request.ServerVariables("PATH_INFO")%>?pag=<%=pagNum+1%><%=strTipo%>">»</a>
  113. <%
  114.     End If
  115. %>
  116.  
  117. </div>
  118.  
  119. <%
  120. rs.close
  121. set rs = nothing
  122. conn.close
  123. set conn = nothing
  124.  
  125. %>
  126.  
  127. </ul>
  128.  
  129. </body>
  130. </html>
  131.  
  132.